Для того, чтобы определить поведение при проверке на истинность объектов классов в python3 есть "магический" метод __bool__(), который был добавлен на замену устаревшему __nonzero__() в python2.
Если данный метод определен в классе, то он будет вызываться при каждой проверке объекта на истинность а также с помощью функции bool(). Метод должен возвращать False или True.
Если __bool__() не определен, будет вызываться метод __len__(), если он определен, и, соответственно, объект будет считаться истинным, если результат __len__() не будет равен нулю. Если в классе не определены ни __len__(), ни __bool__(), все его экземпляры будут истинными.
Для того, чтобы определить поведение при проверке на истинность объектов классов в python3 есть "магический" метод __bool__(), который был добавлен на замену устаревшему __nonzero__() в python2.
Если данный метод определен в классе, то он будет вызываться при каждой проверке объекта на истинность а также с помощью функции bool(). Метод должен возвращать False или True.
Если __bool__() не определен, будет вызываться метод __len__(), если он определен, и, соответственно, объект будет считаться истинным, если результат __len__() не будет равен нулю. Если в классе не определены ни __len__(), ни __bool__(), все его экземпляры будут истинными.
Telegram auto-delete message, expiring invites, and more
elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.
For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.